package com.lianxi.pojo.passport;


import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;

import javax.persistence.*;
import java.util.Date;

/**
 * sso管理的站点，可以认为是sso client
 * @author yangzhenyu
 */
@Entity
@Table(name = "site")
@Data
public class Site {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    /**
     * 站点名称
     */
    @NotBlank
    private String name;

    /**
     * 站点地址，完整的站点域名，除80端口外需完整的端口
     */
    @URL
    private String url;

    /**
     * 首页地址
     */
    @Column(name = "index_url")
    @URL
    private String indexUrl;

    @Temporal(TemporalType.TIMESTAMP)
    @CreationTimestamp
    @Column(name = "create_time",updatable = false)
    private Date createTime;

    /**
     * 站点描述性信息
     */
    private String description;

    /**
     * 系统图标
     */
    @Column(name = "image_url")
    private String imageUrl;

    /**
     * 是否显示
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(columnDefinition = "tinyint",name = "is_show")
    private Boolean isShow;

    /**
     * 排序（权重）
     */
    private int weight = 0;

    /**
     * 站点状态
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(columnDefinition = "tinyint")
    private Boolean status;

    /**
     * 站点是否可删除
     */
    @Enumerated
    @Column(columnDefinition = "tinyint",name = "is_delete")
    private Boolean isdelete ;

    @ApiModelProperty(value = "日志标签")
    @Column(name = "log_tag")
    private String logTag;

    @Override
    public String toString(){
        return new ToStringBuilder(this)
                .append("id",id)
                .append("name",name)
                .append("url",url)
                .toString();
    }
}
